-- ----------------------------
-- 创建表demo
-- ----------------------------
DROP TABLE IF EXISTS "public"."auth_interface_type";
CREATE TABLE "public"."auth_interface_type" (
"refid" varchar(32) COLLATE "default" NOT NULL,
"interface_type" varchar(64) COLLATE "default",
"interface_name" varchar(64) COLLATE "default",
"interface_desc" varchar(128) COLLATE "default",
"active" bool DEFAULT true,
"deleted" bool DEFAULT false,
"version" int4 DEFAULT 1,
"create_user_refid" varchar(32) COLLATE "default" DEFAULT NULL::character varying,
"create_date_time" timestamp(6),
"modify_user_refid" varchar(32) COLLATE "default" DEFAULT NULL::character varying,
"modify_date_time" timestamp(6)
)
WITH (OIDS=FALSE)

;
COMMENT ON TABLE "public"."auth_interface_type" IS '系统对外接口表';
COMMENT ON COLUMN "public"."auth_interface_type"."refid" IS '主键ID';
COMMENT ON COLUMN "public"."auth_interface_type"."interface_type" IS '接口类型';
COMMENT ON COLUMN "public"."auth_interface_type"."interface_name" IS '接口名称';
COMMENT ON COLUMN "public"."auth_interface_type"."interface_desc" IS '接口描述(对接口功能简单的描述)';
COMMENT ON COLUMN "public"."auth_interface_type"."active" IS '有效状态';
COMMENT ON COLUMN "public"."auth_interface_type"."deleted" IS '删除状态';
COMMENT ON COLUMN "public"."auth_interface_type"."version" IS '版本号';
COMMENT ON COLUMN "public"."auth_interface_type"."create_user_refid" IS '创建人ID';
COMMENT ON COLUMN "public"."auth_interface_type"."create_date_time" IS '创建时间';
COMMENT ON COLUMN "public"."auth_interface_type"."modify_user_refid" IS '修改者ID';
COMMENT ON COLUMN "public"."auth_interface_type"."modify_date_time" IS '最后修改时间';

-- ----------------------------
-- 插入数据demo
-- ----------------------------
INSERT INTO "public"."auth_interface_type" ("refid", "interface_type", "interface_name", "interface_desc", "active", "deleted", "version", "create_user_refid", "create_date_time", "modify_user_refid", "modify_date_time") VALUES ('0040c45b1bb24f0faef6525379c81652', 'Upload', '上传服务', '上传服务简介', 't', 'f', '0', '5b2ba188ed4448cf9917028d0b1a01c2', '2018-03-27 17:14:57', '5b2ba188ed4448cf9917028d0b1a01c2', '2018-03-27 17:15:05');
INSERT INTO "public"."auth_interface_type" ("refid", "interface_type", "interface_name", "interface_desc", "active", "deleted", "version", "create_user_refid", "create_date_time", "modify_user_refid", "modify_date_time") VALUES ('0238489178ef4b97aea7d0f638681ace', 'Download', '下载服务', '下载服务简介', 't', 'f', '0', '5b2ba188ed4448cf9917028d0b1a01c2', '2018-03-27 17:16:03', '5b2ba188ed4448cf9917028d0b1a01c2', '2018-03-27 17:16:07');
INSERT INTO "public"."auth_interface_type" ("refid", "interface_type", "interface_name", "interface_desc", "active", "deleted", "version", "create_user_refid", "create_date_time", "modify_user_refid", "modify_date_time") VALUES ('055ea388a9c24197911e1d8a182be0b5', 'Web2D', '2D服务', '2D服务简介', 't', 'f', '0', '5b2ba188ed4448cf9917028d0b1a01c2', '2018-03-27 17:16:42', '5b2ba188ed4448cf9917028d0b1a01c2', '2018-03-27 17:16:47');
INSERT INTO "public"."auth_interface_type" ("refid", "interface_type", "interface_name", "interface_desc", "active", "deleted", "version", "create_user_refid", "create_date_time", "modify_user_refid", "modify_date_time") VALUES ('056ed5cc5bb8424f99abe4ef72d3a1b3', 'Web3D', '3D服务', '3D服务简介', 't', 'f', '0', '5b2ba188ed4448cf9917028d0b1a01c2', '2018-03-27 17:18:47', '5b2ba188ed4448cf9917028d0b1a01c2', '2018-03-27 17:18:50');
INSERT INTO "public"."auth_interface_type" ("refid", "interface_type", "interface_name", "interface_desc", "active", "deleted", "version", "create_user_refid", "create_date_time", "modify_user_refid", "modify_date_time") VALUES ('073855169a9445228f510ed51136c890', 'Report', '报告回传', '报告回传', 't', 'f', '0', '5b2ba188ed4448cf9917028d0b1a01c2', '2018-03-27 17:39:47', '5b2ba188ed4448cf9917028d0b1a01c2', '2018-03-27 17:39:49');

-- ----------------------------
-- 表中新增字段demo
-- ----------------------------
CREATE OR REPLACE FUNCTION "addAuth_interface_type"()
  RETURNS "pg_catalog"."void" AS $BODY$BEGIN
  	IF NOT EXISTS (SELECT * FROM information_schema.COLUMNS WHERE table_schema='public' AND table_name = 'auth_interface' AND column_name = 'interface_type') 
	THEN  
		ALTER TABLE auth_interface ADD interface_type varchar(32);
	END IF;
	IF NOT EXISTS (SELECT * FROM information_schema.COLUMNS WHERE table_schema='public' AND table_name = 'auth_interface' AND column_name = 'interface_type_id') 
	THEN  
		ALTER TABLE auth_interface ADD interface_type_id varchar(32);
	END IF;
END
$BODY$
  LANGUAGE 'plpgsql' VOLATILE COST 100
	;
SELECT "addAuth_interface_type"();
